import request from '@/utils/request'

export function createTask(data) {
  return request({
    url: '/perf/task/create',
    method: 'post',
    data
  })
}

export function search(data) {
  return request({
    url: '/perf/task/search',
    method: 'post',
    data
  })
}

export function updateTaskSummary(data) {
  return request({
    url: '/perf/task/modify',
    method: 'post',
    data
  })
}

export function taskAddScripts(data) {
  return request({
    url: '/perf/task/add/scripts',
    method: 'post',
    data
  })
}

export function taskRemoveScripts(taskId, scriptIds) {
  return request({
    url: '/perf/task/remove/scripts',
    method: 'get',
    params: { taskId, scriptIds }
  })
}

export function taskRemoveCsvs(taskId, csvIds) {
  return request({
    url: '/perf/task/taskRemoveCsvs',
    method: 'get',
    params: { taskId, csvIds }
  })
}

export function searchTaskScriptInfo(id) {
  return request({
    url: '/perf/task/searchTaskScriptInfo',
    method: 'get',
    params: { id }
  })
}

export function deleteTask(id) {
  return request({
    url: '/perf/task/delete',
    method: 'get',
    params: { id }
  })
}

export function execScripts(data) {
  return request({
    url: '/perf/task/exec/scripts',
    method: 'post',
    data
  })
}

export function getScripts(taskId) {
  return request({
    url: '/perf/task/getScripts',
    method: 'get',
    params: { taskId }
  })
}

export function getCsvs(taskId) {
  return request({
    url: '/perf/task/getCsvs',
    method: 'get',
    params: { taskId }
  })
}

export function findReports(taskId, page, size) {
  return request({
    url: '/perf/task/find/reports',
    method: 'get',
    params: { taskId, page, size }
  })
}

export function findScriptReports(taskId, scriptId, page, size) {
  return request({
    url: '/perf/task/find/script/reports',
    method: 'get',
    params: { taskId, scriptId, page, size }
  })
}

export function updateScriptUsersOrQps(taskId, scriptId, key, value) {
  return request({
    url: '/perf/task/update/script/usersOrQps',
    method: 'get',
    params: { taskId, scriptId, key, value }
  })
}
